package it.unibo.convoycruisecontrol.boatsubsystem.test.unit;

import static org.junit.Assert.*;

import it.unibo.convoycruisecontrol.boatsubsystem.SendingNavigationInfo;
import it.unibo.convoycruisecontrol.boatsubsystem.test.mock.MockLocation;
import it.unibo.convoycruisecontrol.boatsubsystem.test.mock.MockNavigationInfo;
import it.unibo.convoycruisecontrol.boatsubsystem.test.mock.MockSendingNavigationInfo;
import it.unibo.util.information.InformationConverter;
import it.unibo.util.information.PrologInformationConverter;

import org.junit.BeforeClass;
import org.junit.Test;

// Vedere anche test di it.unibo.util.information
public class SendingNavigationInfoTestCase {

	static MockSendingNavigationInfo sendingNavInfo;
	static MockNavigationInfo navInfo;
	static int DT = 1000;
	static InformationConverter infoConverter;
	float speed = (float) 45.0;
	float longitude = (float) 67.0;
	float latitude = (float) 34.0;
	static int seqNum = 0;
	String message = "boatInfo([],speed("+ speed +"),longitude(" + longitude + "),latitude(" + latitude + "),sequenceNumber(" + seqNum + "))";

	@BeforeClass
	public static void beforeClass()
	{
		try {
			navInfo = new MockNavigationInfo(seqNum);
			infoConverter = new PrologInformationConverter();
			sendingNavInfo = new MockSendingNavigationInfo(DT, navInfo, infoConverter);
		} catch (Exception e) {
			e.printStackTrace();
			fail();
		}
	}

	@Test(expected=IllegalArgumentException.class)
	public void testCreation() throws Exception 
	{
		new SendingNavigationInfo(-5, null, null);
	}

	@Test
	public void testCreateInformations()
	{
		try
		{
			navInfo.setCurrentSpeed(speed);
			navInfo.setCurrentLocation(new MockLocation(latitude, longitude, 0));
			assertEquals(message, sendingNavInfo.createInformations());
		}
		catch (Exception e) {
			e.printStackTrace();
			fail();
		}
	}

}
